//
//  PersonalCell.m
//  ChatForHot
//
//  Created by wr on 2018/10/9.
//  Copyright © 2018年 FLY. All rights reserved.
//

#import "PersonalCell.h"
#import "PersonalCellModel.h"

@interface PersonalCell ()

@property (nonatomic, strong, readwrite) UILabel *HOTCHATtitle;
@property (nonatomic, strong, readwrite) UILabel *HOTCHATtipLable;
@property (nonatomic, strong, readwrite) UIImageView *HOTCHATarrowImageView;
@property (nonatomic, strong, readwrite) UIImageView *HOTCHATpersonalIcon;
@property (nonatomic, strong, readwrite) UIView *HOTCHATthickLineView;
@property (nonatomic, strong, readwrite) UIView *HOTCHATthinLineView;

@end

@implementation PersonalCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self HOTCHATinitSubViews];
    }
    return self;
}

- (void)HOTCHATinitSubViews {
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.HOTCHATtitle = [[UILabel alloc] init];
    self.HOTCHATtitle.font = [UIFont systemFontOfSize:13];
    self.HOTCHATtitle.textColor = [UIColor colorFromHexString:@"111111"];
    [self.contentView addSubview:self.HOTCHATtitle];
    
    self.HOTCHATtipLable = [[UILabel alloc] init];
    self.HOTCHATtipLable.font = [UIFont systemFontOfSize:12];
    self.HOTCHATtipLable.textColor = [UIColor colorFromHexString:@"AAAAAA"];
    self.HOTCHATtipLable.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:self.HOTCHATtipLable];
    
    self.HOTCHATarrowImageView = [[UIImageView alloc] init];
    [self.HOTCHATarrowImageView setImage:[UIImage imageNamed:@"personal_arrow"]];
    [self.contentView addSubview:self.HOTCHATarrowImageView];
    
    self.HOTCHATpersonalIcon = [[UIImageView alloc] init];
    [self.contentView addSubview:self.HOTCHATpersonalIcon];
    
    self.HOTCHATthinLineView = [[UIView alloc] init];
    self.HOTCHATthinLineView.backgroundColor = HOTCHATrgb(230, 230, 230);
    [self.contentView addSubview:self.HOTCHATthinLineView];
    
    self.HOTCHATthickLineView = [[UIView alloc] init];
    self.HOTCHATthickLineView.backgroundColor = [UIColor colorFromHexString:@"EEEEEE"];
    [self.contentView addSubview:self.HOTCHATthickLineView];
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.HOTCHATpersonalIcon.size = CGSizeMake(24, 24);
    if (!self.model.thickLineIsHidden) {
        self.HOTCHATpersonalIcon.top = 11;
    }else {
        self.HOTCHATpersonalIcon.centerY = self.contentView.centerY;
    }
    self.HOTCHATpersonalIcon.left = 18;
    
    self.HOTCHATtitle.size = CGSizeMake(kScreenWidth - 150, 15);
    self.HOTCHATtitle.centerY = self.HOTCHATpersonalIcon.centerY;
    self.HOTCHATtitle.left = self.HOTCHATpersonalIcon.right + 11;

    self.HOTCHATarrowImageView.size = CGSizeMake(7, 11);
    self.HOTCHATarrowImageView.centerY = self.HOTCHATpersonalIcon.centerY;
    self.HOTCHATarrowImageView.left = kScreenWidth - 25;

    self.HOTCHATtipLable.size = CGSizeMake(200, 13);
    self.HOTCHATtipLable.right = self.HOTCHATarrowImageView.left - 15;
    self.HOTCHATtipLable.centerY = self.HOTCHATpersonalIcon.centerY;
    
    self.HOTCHATthinLineView.size = CGSizeMake(kScreenWidth - 15, 1 / [[UIScreen mainScreen] scale]);
    self.HOTCHATthinLineView.left = 15;
    self.HOTCHATthinLineView.bottom = self.contentView.bottom - (1 / [[UIScreen mainScreen] scale]);
    
    self.HOTCHATthickLineView.size = CGSizeMake(kScreenWidth - 15, 2.5);
    self.HOTCHATthickLineView.left = 15;
    self.HOTCHATthickLineView.bottom = self.contentView.bottom - 7.5;
}

- (void)HOTCHATbind:(PersonalCellModel *)model {
    _model = model;
    self.HOTCHATtitle.text = model.title;
    self.HOTCHATtipLable.text = model.info;
    [self.HOTCHATpersonalIcon setImage:[UIImage imageNamed:model.icon]];
    self.HOTCHATthinLineView.hidden = model.thinLineIsHidden;
    self.HOTCHATthickLineView.hidden = model.thickLineIsHidden;
}
@end
